package com.lframework.xingyun.basedata.vo.product.spu;

import java.math.BigDecimal;
import javax.validation.Valid;
import javax.validation.constraints.NotBlank;

import com.lframework.starter.web.vo.BaseVo;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;

import com.lframework.starter.web.components.validation.IsNumberPrecision;
import com.lframework.xingyun.basedata.vo.product.info.ProductPropertyRelationVo;
import io.swagger.annotations.ApiModelProperty;
import com.lframework.starter.web.components.validation.TypeMismatch;
import org.hibernate.validator.constraints.Length;
import java.io.Serializable;
import java.util.List;

import lombok.Data;

@Data
public class CreateProductSpuVo implements BaseVo, Serializable {

    private static final long serialVersionUID = 1L;

    /**
     * 商品编码
     */
    @ApiModelProperty(value = "商品编码", required = true)
    @NotBlank(message = "请输入商品编码！")
    @Length(message = "商品编码最多允许20个字符！")
    private String code;

    /**
     * 商品名称
     */
    @ApiModelProperty(value = "商品名称", required = true)
    @NotBlank(message = "请输入商品名称！")
    @Length(message = "商品名称最多允许100个字符！")
    private String name;

    /**
     * 商品简称
     */
    @ApiModelProperty(value = "商品简称", required = true)
    @Length(message = "商品简称最多允许100个字符！")
    private String shortName;

    /**
     * 类目ID
     */
    @ApiModelProperty(value = "类目ID", required = true)
    @NotBlank(message = "请输入类目ID！")
    @Length(message = "类目ID最多允许32个字符！")
    private String categoryId;

    /**
     * 品牌ID
     */
    @ApiModelProperty(value = "品牌ID", required = true)
    @NotBlank(message = "请输入品牌ID！")
    @Length(message = "品牌ID最多允许32个字符！")
    private String brandId;

    /**
     * 商品类型
     */
    @ApiModelProperty(value = "商品类型", required = true)
    @NotNull(message = "请选择商品类型！")
    @TypeMismatch(message = "商品类型格式有误！")
    private Integer productType;

    /**
     * 规格
     */
    @ApiModelProperty("规格")
    @Length(message = "规格最多允许20个字符！")
    private String spec;

    /**
     * 重量（kg）
     */
    @ApiModelProperty("重量（kg）")
    @TypeMismatch(message = "重量（kg）格式有误！")
    @IsNumberPrecision(message = "重量（kg）最多允许2位小数！", value = 2)
    private BigDecimal weight;

    /**
     * 体积（cm3）
     */
    @ApiModelProperty("体积（cm3）")
    @TypeMismatch(message = "体积（cm3）格式有误！")
    @IsNumberPrecision(message = "体积（cm3）最多允许2位小数！", value = 2)
    private BigDecimal volume;

    /**
     * 商品属性
     */
    @ApiModelProperty(value = "商品属性")
    @Valid
    private List<ProductPropertyRelationVo> properties;

    /**
     * 商品SKU集合
     */
    @Valid
    @ApiModelProperty("商品SKU集合")
    @NotNull(message = "请填写商品SKU信息！")
    @Size(min = 1, message = "请填写商品SKU信息！")
    private List<CreateProductSpuItemVo> skuItems;
}
